
#include <stdio.h>
#include <stdlib.h>

#include "system.h"
#include "network.h"
#include "yjktypes.h"
#include "scheme.h"

#define TAG(X) ((X).mask.tag = (X).mask.tag | 0x1)

YJK_RATIO * 
make_ratio(YJK_OBJECT numerator, YJK_OBJECT denominator)
{
  YJK_OBJECT o;
  o.ratio = malloc(sizeof(YJK_RATIO));
  o.head->type  = YJK_RATIO_T;
  o.head->size  = sizeof(YJK_RATIO);
  o.head->flags = 0;

  o.ratio->numerator = numerator;
  o.ratio->denominator = denominator;

  TAG(o);

  return o.ratio;
}


YJK_COMPLEX *
make_complex(YJK_OBJECT real, YJK_OBJECT imaginary)
{
  YJK_OBJECT o;
  o.complex = malloc(sizeof(YJK_COMPLEX));
  o.head->type = YJK_COMPLEX_T;
  o.head->size = sizeof(YJK_RATIO);
  o.head->flags = 0;

  o.complex->rpart = real;
  o.complex->ipart = imaginary;
  
  TAG(o);
  
  return o.complex;
}


int
main(int argc, char *argv[])
{

  yjk_scheme_parse("(define (x y z) (add y z)) (\"Hello\")");
  yjk_init();
  
  YJK_OBJECT o;
  o.fixnum = 100;
  YJK_OBJECT r;
  r.ratio = make_ratio(o, o);

  printf("Ratio: %x\n", (int) r.fixnum);
  printf("Ratio: %d\n", yjk_get_type(r));

  return 0;
}
